package com.github.cyf.util;

/**
 * @author chenyifan
 * @create 2024-04-14 19:47
 */
public class PrintUtil {

    private Class clazz;
    private String rank;

    public PrintUtil(Class clazz) {
        this.clazz = clazz;
        this.rank = clazz.getSimpleName();
    }

    public void printInterceptorBegin() {
        System.out.println("\n=============================> " + rank + " 开始");
    }

    public void printInterceptorEnd() {
        System.out.println("=============================> " + rank + " 结束\n");
    }

    public void printSql(String mapperId, String sql) {
        System.out.println(rank + " ==> " + mapperId + " 方法对应 sql 执行语句: " + sql);
    }

    public void printSqlTime(String mapperId, long startTime, long endTime) {
        System.out.println(rank + " ==> " + mapperId + " 方法对应 sql 执行时间: " + (endTime - startTime) + " ms");
    }

}
